#ifndef QBCIHDRENDERSTATICFUNC_H
#define QBCIHDRENDERSTATICFUNC_H

#include <QBciRender>
#include <QLogger>
#include <QObject>
#include <QSerialPort>
#include <QtDebug>
#include <iostream>

class QBciHDRenderStaticFunc : public QObject {
  Q_OBJECT
public:
  static QBciHDRenderStaticFunc *getinstance();

private:
  QBciHDRenderStaticFunc();
  ~QBciHDRenderStaticFunc();
  QBciHDRenderStaticFunc(const QBciHDRenderStaticFunc &);
  QBciHDRenderStaticFunc &operator==(const QBciHDRenderStaticFunc &);

public:
  struct BlockConfig {
    QString Label;
    int ID = -1;
    double Freq = -1;
    double Duti = -1;
    bool Enable = true;
    bool Flick = true;
  };

  void setBlockEnable(const int &ID, const bool &enable);
  void setBlockFreq(const int &ID, const double &freq);
  void setBlockDuti(const int &ID, const double &duti);
  void setBlockLabel(const int &ID, const QString &label);
  void setBlockFlick(const int &ID, const bool &flick);

  void setBlock(const int &ID, const bool &enable, const double &freq,
                const double &duti, const QString &label);

  QByteArray getConstruction();
  void allBlockInit();
  void resetAllBlock();

  void setWaveType(QBciRender::WaveType wave);
  void setEnableWave(const int &ID, const bool &flag);

public:
  void setPort(QString portname);
  void write(const QByteArray &mesg);

private:
  static QBciHDRenderStaticFunc *Instance;
  QSerialPort *serial;
  // block Num
  int BlockNum = 13;
  // save config
  QList<BlockConfig> ConfigList;
  // wave type
  QBciRender::WaveType Wave;

public:
  static int HDRenderCount;

private:
  static int EnableWaveCount;

signals:
  void newConstruction(const QByteArray &mesg);
};

#endif // QBCIHDRENDERSTATICFUNC_H
